<template>
	<view class="container">
		<view class="map-container">
			<map
				class="map"
				:latitude="latitude"
				:longitude="longitude"
				:markers="markers"
				:polygons="polygons"
				show-location
				:scale="scale"
				@regionchange="regionChange"
			></map>
		</view>

		<!-- 点名2 -->
		<view class="gz">
			<view class="dh">
			  <view class="img">
			    <image src="/static/imgs/cowbh.png"></image>
			  </view>
			  <view class="msg">
			    <view class="bh">牛的编号</view>
			    <view class="bh" style="color: #9d9d9d;">IMEI: 866452264124</view>
			  </view>
			  <view class="dh-text">
			    <text>切换</text>
			  </view>
			</view>
			
			<view class="infor">
				<text>定位时间：2024-01-05 12 : 33 : 22</text>
			</view>
			<view class="infor">
				<text>定位地点：贵州省黔东南雷山县望丰乡</text>
			</view>
			<view class="infor">
				<text>距离：1km</text>
			</view>
			
			<view style="padding: 30rpx;">
				<uv-button 
				type="primary" 
				text="闪光响铃" 
				:plain="true"
				color="#0bcb75"
				shape="circle"
				></uv-button>
			</view>
			
			<view class="btn">
				<view class="btn-item">
					<uv-button
					type="primary" 
					text="地图导航" 
					color="#0bcb75"
					shape="circle"
					></uv-button>
				</view>
				<view class="btn-item">
					<uv-button
					type="primary" 
					text="直线导航" 
					color="#0bcb75"
					shape="circle"
					></uv-button>
				</view>
			</view>
		</view>
		
		<!-- 点名3 -->
		<!-- <view class="zxdh">
			<view class="wz">
				<view class="js">
					<text>小黄牛位于您</text>
				</view>
				<view class="fx">
					西北方向800米
				</view>
			</view>
			<view class="ts">
				<text>请沿着指示方向前进</text>
			</view>
		</view> -->
	</view>
</template>

<script setup>
import { ref, computed } from 'vue';
import img from '@/static/imgs/cowbh.png';

const latitude = ref(26.405700);
const longitude = ref(108.015950);

const markers = ref([
  {
    id: 0,
    latitude: 26.407720,
    longitude: 108.015304,
    iconPath: img,
    anchor: { x: 0.5, y: 0.5 },
	width: 30,
	height: 30,
  }
]);
// 地图区域变化事件
const regionChange = (e) => {
  if (e.type === 'end') {
    scale.value = e.detail.scale;
  }
};
</script>


<style scoped lang="scss">
	.container {
		width: 100%;
		height: 100vh;
		background-color: #f5f5f5;
	}

	.map-container {
		width: 100%;
		height: 100%;
		position: relative;
	}

	.map {
		width: 100%;
		height: 100%;
	}
	// 点名2
	.gz {
		position: absolute;
		bottom: 2%;
		left: 50%;
		transform: translateX(-50%);
		width: 692rpx;
		height: 508rpx;
		background-color: white;
		font-size: 16px;
		box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
		border-radius: 20rpx;
	}
	.dh{
	  width: 648rpx;
	  height: 132rpx;
	  background-color: #fff;
	  display: flex;
	  border-bottom:1px solid  #efefef;
	  margin: 0 auto;
	  .img{
	    width: 120rpx;
	    height: 120rpx;
	  }
	  .msg{
	    flex:1;
	    padding-top: 34rpx;
	  }
	  .dh-text{
	    width: 60rpx;
	    height: 100%;
	    display: flex;
	    align-items: center;
		color: #0bcb75;
		margin-right: 9rpx;
	  }
	}
	image{
	  width: 72rpx;
	  height: 72rpx;
	  margin: 34rpx 0rpx;
	}
	.bh{
	  font-size: 26rpx;
	  margin-bottom: 10rpx;
	  margin-left: -24rpx;
	}
	
	// 信息
	.infor{
		font-size: 26rpx;
		color: #666666;
		margin-left: 45rpx;
		margin-top: 18rpx;
	}
	
	// 按钮
	.btn{
		width: 630rpx;
		height: 72rpx;
		margin-left: 30rpx;
		display: flex;
		justify-content: space-between;
		.btn-item{
			width: 300rpx;
			height: 72rpx;
		}
	}
	
	// 点名3
	.zxdh{
		position: absolute;
		bottom: 2%;
		left: 50%;
		transform: translateX(-50%);
		width: 692rpx;
		height: 142rpx;
		background-color: white;
		font-size: 16px;
		box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
		border-radius: 20rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.wz{
		display: flex;
		font-size: 30rpx;
		margin-top: 32rpx;
		.js{
			margin-right: 20rpx;
		}
		.fx{
			color: #0bcb75;
		}
	}
	.ts{
		color:#999999;
		font-size: 25rpx;
	}
</style>